﻿using System.Collections.Generic;

namespace Com.FastSearch.SharePoint.Interfaces
{
    /// <summary>
    /// This interface defines the search settings and search result store,
    /// iow. the required input and the output to/from the ESP search system.
    ///
    /// Making a convenient interface for memory handling, this is a typical
    /// challenge between web components. Implementation can be done using either the Session
    /// or HttpContext.Current.Items collections for storing these data and
    /// making them easily available between components such as web parts.
    /// (See singleton pattern)
    /// </summary>
    public interface IESPSearchSettings : IESPSearchParams
    {
        /// <summary>
        /// Number of results returned from the search.<br></br>
        /// Results returned are always from <see cref="IESPSearchParams.Start1"/> to NumberOfResultsPerPage.
        /// </summary>
        int NumberOfResultsPerPage { get; set; }

        /// <summary>
        /// The search view the search shall be performed in.
        /// </summary>
        string ESPSearchView { get; set; }

        /// <summary>
        /// Shall synonym expansion for the search be enabled/disabled.
        /// Defaults to false.
        /// </summary>
        string SynonymsEnabled { get; set; }

        /// <summary>
        /// Shall lemmatization for the search be enabled/disabled.
        /// Defaults to false.
        /// </summary>
        string LemmatizationEnabled { get; set; }

        /// <summary>
        /// Which kind of spellchecking shall be used.
        /// <remarks>ESP suppports the following values:<br></br>
        /// <b>off:</b> Does not perform spellchecking<br></br>
        /// <b>auto:</b> Does perform an automatic requery with the spellchecking applied if no results where returned for the original search<br></br>
        /// <b>suggest.</b> Suggest a spellchecked query so the user can click on the changed suggested query instead of autosubmitting it.<br></br>
        /// </remarks>
        /// </summary>
        string Spellcheck { get; set; }

        /// <summary>
        /// The default Sorting which shall be used if no <see cref="CustomResultSorting"/> is specified.
        /// </summary>
        string ResultSorting { get; set; }

        /// <summary>
        /// Holds the Query Template String which is used to build up the final query sent to ESP.
        /// </summary>
        string QueryTemplate { get; set; }

        /// <summary>
        /// Static query properties sent to the Search Server.
        /// <remarks>
        /// The string is parsed and the property values are URLEncoded.
        /// </remarks>
        /// </summary>
        string StaticCustomQueryProperties { get; set; }

        /// <summary>
        /// Profperty name used to extract the query string from the Request.
        /// </summary>
        string QueryURLPropertyName { get; set; }

        /// <summary>
        /// Holds the connection(s) string to the QRServer
        /// </summary>
        string ESPConnection { get; set;}

        /// <summary>
        /// Get the navigation search parameter used to specify which navigators should be returned.
        /// Returns a parameter based on all the navigators added using <see cref="AddNavigator"/>.
        /// </summary>
        string Navigation { get; }

        /// <summary>
        /// Request that the given navigator is included in the search results.
        /// </summary>
        /// <param name="navigator">The navigator to be included.</param>
        void AddNavigator(IESPNavigatorDefinition navigator);

        /// <summary>
        /// Result sorting used for the search.
        /// </summary>
        string CustomResultSorting { get; set;}

        /// <summary>
        /// Add a custom parameter to the Search Settings.
        /// Can be used for parameters which are not explicitly exposed in the interface and 
        /// are used for special searches. 
        /// Example can be coordinates for geo search.
        /// The added parameter and it's values are added to the search query.        
        /// </summary>
        /// <param name="parameterName">name of the parameter to be added to the search settings</param>
        /// <param name="parameterValue">value of the parameter to be added to the search settings</param>
        void SetCustomParameterByName(string parameterName, string parameterValue);

        /// <summary>
        /// Return the value of a custom parameter by name
        /// </summary>
        /// <param name="parameterName">name of the search parameter which shall be returned</param>
        /// <returns>value of the search parameter</returns>
        string GetCustomParameterByName(string parameterName);

        /// <summary>
        /// Return a list of key value pairs of all custom parameters which have been added by the <see cref="SetCustomParameterByName"/>
        /// method
        /// </summary>
        /// <returns>List of KeyValuPairs of the custom parameters</returns>
        List<KeyValuePair<string, string>> GetAllCustomParameter();

        /// <summary>
        /// 
        /// </summary>
        string WeightedSearchQuery { get; set; }

    }
}
